package com.zjb.accountManager.intercepters;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class CheckLogin implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		Integer userId = controller.getSessionAttr("userId");
		String account = controller.getSessionAttr("account");
		
		if (userId != null && !userId.equals(0)) {
			inv.invoke();
			return;
		}
		
		if (account != null && !account.equals(0)) {
			inv.invoke();
			return;
		}
		
		controller.redirect("/cp0000");
	}
	

}
